package com.appwoo.txtws.service;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import com.appwoo.android.exception.NotFoundNetWorkException;
import com.appwoo.android.exception.TimeOutException;
import com.appwoo.txtws.bean.DeviceBean;
import com.appwoo.txtws.bean.LocationBean;
import com.appwoo.txtws.bean.StateBean;
import com.appwoo.txtws.component.DBHelper;
import com.appwoo.txtws.component.Global;
import com.appwoo.txtws.component.LocationHelper;
import com.appwoo.txtws.component.Logger;
import com.appwoo.txtws.component.MyHelper;
import com.appwoo.txtws.component.RqSP;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import org.xmlpull.v1.XmlPullParserException;

public class RQLocation
{
  private String alertString;
  private String alertStringSend;
  private Context context = null;
  private SharedPreferences.Editor editor;
  private LoginService loginService = null;
  private SharedPreferences sp;
  private SharedPreferences.Editor userEditor;
  private String userName;
  private SharedPreferences userSp;

  public RQLocation(Context paramContext)
  {
    this.context = paramContext;
    this.userName = Global.getIMEI(paramContext);
    this.loginService = new LoginService();
    if ((this.sp == null) || (this.editor == null))
    {
      this.sp = paramContext.getSharedPreferences("user_location", 0);
      this.editor = this.sp.edit();
    }
    if ((this.userSp == null) || (this.userEditor == null))
    {
      this.userSp = paramContext.getSharedPreferences("user_info", 0);
      this.userEditor = this.userSp.edit();
    }
  }

  public static void addOp(String paramString, SharedPreferences paramSharedPreferences)
  {
    String str = paramSharedPreferences.getString("user", "");
    if (!str.equals(""))
      MyHelper.insertLog(paramString, str);
  }

  public String UDManageUser(String paramString)
  {
    try
    {
      this.alertString = this.loginService.UDManageUser(Global.USERNAME, this.userName, paramString, this.context).getCode();
      return this.alertString;
    }
    catch (IOException localIOException)
    {
      while (true)
        this.alertStringSend = "服务器返回数据不正确1";
    }
    catch (XmlPullParserException localXmlPullParserException)
    {
      while (true)
        this.alertStringSend = "服务器返回数据不正确2";
    }
    catch (TimeOutException localTimeOutException)
    {
      while (true)
        this.alertStringSend = "连接超时";
    }
    catch (NotFoundNetWorkException localNotFoundNetWorkException)
    {
      while (true)
        if (localNotFoundNetWorkException != null)
        {
          localNotFoundNetWorkException.getClass();
          this.alertStringSend = "没有连接到网络";
        }
    }
  }

  public void addLogPlat(DeviceBean paramDeviceBean)
  {
    try
    {
      this.alertString = this.loginService.addLogPlat(paramDeviceBean, this.context).getCode();
      if (this.alertString.equals("0"))
      {
        SharedPreferences.Editor localEditor = this.context.getSharedPreferences("firstLogin", 0).edit();
        localEditor.putString("logplat", "yes");
        localEditor.commit();
      }
      return;
    }
    catch (IOException localIOException)
    {
      this.alertStringSend = "服务器返回数据不正确1";
      return;
    }
    catch (XmlPullParserException localXmlPullParserException)
    {
      this.alertStringSend = "服务器返回数据不正确2";
      return;
    }
    catch (TimeOutException localTimeOutException)
    {
      this.alertStringSend = "连接超时";
      return;
    }
    catch (NotFoundNetWorkException localNotFoundNetWorkException)
    {
      localNotFoundNetWorkException.getClass();
      this.alertStringSend = "没有连接到网络";
      return;
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
  }

  public void getIsBind()
  {
    try
    {
      String str = Global.USERNAME;
      if (str == null)
        str = "@@@";
      StateBean localStateBean = this.loginService.RQManageUserStatus(str, this.userName, this.context);
      if (localStateBean.getBindStatus() != null)
      {
        DBHelper localDBHelper = new DBHelper(this.context);
        if (localStateBean.getBindStatus().equals("1"))
        {
          Global.isBinded = 1;
          this.userEditor.putInt("isBinded2", 1);
          this.userEditor.commit();
          localDBHelper.updateLogin(Global.USERNAME, "1");
          return;
        }
        Global.isBinded = 0;
        this.userEditor.putInt("isBinded2", 0);
        this.userEditor.commit();
        localDBHelper.updateLogin(Global.USERNAME, "0");
        return;
      }
    }
    catch (IOException localIOException)
    {
      this.alertStringSend = "服务器返回数据不正确1";
      return;
      Global.isBinded = -1;
      return;
    }
    catch (XmlPullParserException localXmlPullParserException)
    {
      this.alertStringSend = "服务器返回数据不正确2";
      return;
    }
    catch (TimeOutException localTimeOutException)
    {
      this.alertStringSend = "连接超时";
      return;
    }
    catch (NotFoundNetWorkException localNotFoundNetWorkException)
    {
      localNotFoundNetWorkException.getClass();
      this.alertStringSend = "没有连接到网络";
    }
  }

  public String getSwitch()
  {
    return this.userSp.getString("type", "4");
  }

  public void rqSwitch()
  {
    this.alertString = "";
    try
    {
      StateBean localStateBean = this.loginService.isAddLocation(this.userName, this.context);
      if ((localStateBean.getType() != null) && (localStateBean.getType().equals("4")))
      {
        this.alertString = (localStateBean.getType() + "," + localStateBean.getSttm());
        this.userEditor.putString("type", localStateBean.getType());
        this.userEditor.commit();
      }
      while (true)
      {
        System.out.println("-----------------\n-返回值--->" + this.alertString + "\n---------------");
        return;
        this.userEditor.putString("type", "5");
        this.userEditor.commit();
        this.alertString = "5";
      }
    }
    catch (IOException localIOException)
    {
      while (true)
        this.alertString = ("服务器返回数据不正确3" + localIOException.getMessage());
    }
    catch (XmlPullParserException localXmlPullParserException)
    {
      while (true)
        this.alertString = "服务器返回数据不正确4";
    }
    catch (TimeOutException localTimeOutException)
    {
      while (true)
        this.alertString = "连接超时";
    }
    catch (NotFoundNetWorkException localNotFoundNetWorkException)
    {
      while (true)
      {
        localNotFoundNetWorkException.getClass();
        this.alertString = "没有连接到网络";
      }
    }
  }

  public void rqSwitch(StateBean paramStateBean)
  {
    this.alertString = "";
    String str = paramStateBean.getLocType();
    if (str != null)
      if (str.equals("4"))
      {
        this.alertString = (str + "," + paramStateBean.getLocSttm());
        this.userEditor.putString("type", str);
        this.userEditor.putString("locTime", paramStateBean.getLocSttm());
        this.userEditor.putString("locDesc", paramStateBean.getLocDesc());
        this.userEditor.commit();
        this.alertString = "4";
        new RqSP().setLocDesc(paramStateBean.getLocDesc(), this.context);
        WebTimeControlService.myLocationService.openLocationTask();
        WebTimeControlService.myLocationService.doLocation();
      }
    while (true)
    {
      System.out.println("-----------------\n-返回值--->" + this.alertString + "\n---------------");
      return;
      this.userEditor.putString("type", "5");
      this.userEditor.putString("locTime", paramStateBean.getLocSttm());
      this.userEditor.putString("locDesc", paramStateBean.getLocDesc());
      this.userEditor.commit();
      this.alertString = "5";
      continue;
      this.alertString = this.userSp.getString("type", "-1");
    }
  }

  public void udLogPlat(DeviceBean paramDeviceBean)
  {
    try
    {
      this.alertString = this.loginService.udLogPlat(paramDeviceBean, this.context).getCode();
      if (this.alertString.equals("0"))
      {
        SharedPreferences.Editor localEditor = this.context.getSharedPreferences("firstLogin", 0).edit();
        localEditor.putString("logplat", "yes");
        localEditor.commit();
      }
      return;
    }
    catch (IOException localIOException)
    {
      this.alertStringSend = "服务器返回数据不正确1";
      return;
    }
    catch (XmlPullParserException localXmlPullParserException)
    {
      this.alertStringSend = "服务器返回数据不正确2";
      return;
    }
    catch (TimeOutException localTimeOutException)
    {
      this.alertStringSend = "连接超时";
      return;
    }
    catch (NotFoundNetWorkException localNotFoundNetWorkException)
    {
      localNotFoundNetWorkException.getClass();
      this.alertStringSend = "没有连接到网络";
    }
  }

  public void upLocation()
  {
    int i;
    int j;
    do
      try
      {
        LocationHelper localLocationHelper = new LocationHelper(this.context);
        localLocationHelper.delData();
        ArrayList localArrayList = localLocationHelper.queryLocation();
        i = localArrayList.size();
        if (i > 0)
        {
          StateBean localStateBean = this.loginService.addLocation(this.userName, localArrayList, this.context);
          if ((localStateBean.getCode() != null) && (localStateBean.getCode().equals("0")))
          {
            this.alertStringSend = localStateBean.getCode();
            j = 0;
            continue;
            String str = ((LocationBean)localArrayList.get(j)).getId();
            Logger.d("bod", "新增定位信息update--id--" + str);
            localLocationHelper.updateLocation(str);
            j++;
            continue;
          }
          this.alertStringSend = localStateBean.getDesc();
        }
      }
      catch (IOException localIOException)
      {
        this.alertStringSend = "服务器返回数据不正确1";
        return;
        Logger.v("bod", "无定位数据可上传");
        return;
      }
      catch (XmlPullParserException localXmlPullParserException)
      {
        this.alertStringSend = "服务器返回数据不正确2";
        return;
      }
      catch (TimeOutException localTimeOutException)
      {
        this.alertStringSend = "连接超时";
        return;
      }
      catch (NotFoundNetWorkException localNotFoundNetWorkException)
      {
        localNotFoundNetWorkException.getClass();
        this.alertStringSend = "没有连接到网络";
        return;
      }
    while (j < i);
  }
}

/* Location:           C:\Documents and Settings\Administrator\classes_dex2jar.jar
 * Qualified Name:     com.appwoo.txtws.service.RQLocation
 * JD-Core Version:    0.6.2
 */